package com.my;

import com.my.dao.UserDao;
import com.my.entiy.User;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Hello world!
 *
 */
//@EnableConfigServer
@SpringBootApplication
@RestController
@MapperScan("com.my.dao")
public class App  {
    private static final Logger LOG = LoggerFactory.getLogger(App.class);

    @Value("${spring.datasource.url}")
    private String url;
    @Autowired
    private UserDao userDao;

    @RequestMapping("/hello/{id}")
    @ResponseBody
    public User getUser(@PathVariable("id") int id){
        LOG.info("id="+id);
        LOG.info("url="+url);
        User userInfo = userDao.findUser(id);
        return userInfo;
    }
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}
